<?php
namespace App\Models;

/**
 * 会员转账日志类
 */
class MSwitchCoinLog extends BaseModel
{
    public $table = "switch_coin_logs";

    /**
     * 会员币种转换数据效验规则
     * $flag 0 = rules  1 = msg
     */
    public static function withdrawRulMsg($flag)
    {
        $rules = array(
            "real_coin"  => "required|numeric",
            'money'      => 'required|numeric|between:1,999999999',
            'final_coin' => 'required|numeric',
            'safepass'   => 'required|between:6,50'
        );

        $msg = array(
            "wallet.required"   => "请选择提现钱包！",
            "money.required"    => "请输入提现金额！",
            "intro.required"    => "请必须填写收款备注！",
            "safepass.required" => "请填写交易密码！"
        );

        if ($flag == 0) {
            return $rules;
        } else {
            return $msg;
        }
    }

    /**
     * 记录一条币种转换日志
     */
    public static function log($uid, $real_coin, $final_coin, $real_money, $tax_money, $final_money)
    {
        $log = new MSwitchCoinLog();
        $log->no = onlyNo();
        $log->uid = $uid;
        $log->real_coin = $real_coin;
        $log->final_coin = $final_coin;
        $log->real_money = $real_money;
        $log->tax_money = $tax_money;
        $log->final_money = $final_money;
        $log->time = time();
        return $log->save();
    }
}